package com.jt.config;

import javax.servlet.FilterRegistration;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;

import org.springframework.web.filter.DelegatingFilterProxy;
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;

public class AppWebInitializer extends AbstractAnnotationConfigDispatcherServletInitializer{
	@Override
	public void onStartup(ServletContext servletContext) throws ServletException {
		// TODO Auto-generated method stub
		super.onStartup(servletContext);
		//注册Filter对象
		//项目没有配置文件web.xml,并且此Filter不是自己写的
		FilterRegistration.Dynamic dy = servletContext.addFilter("delegatingFilterProxy", DelegatingFilterProxy.class);
		dy.setInitParameter("targetBeanName", "shiroFilter");
		dy.addMappingForUrlPatterns(
				null, //拦截类型
				false, 
				"/*");//拦截对象路径
	}
	
	@Override
	protected Class<?>[] getRootConfigClasses() {
		// TODO Auto-generated method stub
		return new Class[]{AppRootConfig.class};
	}

	@Override
	protected Class<?>[] getServletConfigClasses() {
		// TODO Auto-generated method stub
		return new Class[]{AppServletConfig.class};
	}

	@Override
	protected String[] getServletMappings() {
		// TODO Auto-generated method stub
		return new String[]{"*.do"};
	}
}
